<template>
    <el-table-column  align="left" v-bind="$attrs" v-on="$listeners"  :width="width"  :formatter="genderFormatter"/>
</template>
<script>
    export default {
        name:"MyGenderColumn",
        props:{
          width:{
              type:String,
              default:"60"
          }
        },
        methods:{
            genderFormatter(row){
                let keyList = this.$attrs.prop.split(".");
                let count = 0;
                let value = row;
                while (count < keyList.length){
                    value = value[keyList[count]];
                    count++
                }
                if(value==1){
                    return "男"
                }else if(value==2){
                    return "女"
                }else if(value==0){
                    return "未知"
                }else {
                    return ""
                }
            },
            getValue(obj,key){
                return obj[key]
            }
        }
    }
</script>
